using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class Block : MonoBehaviour
{
    [SerializeField] private Text TextNum;
    [SerializeField] private Image ImgBg;
    [SerializeField] private Sprite[] NumSprites;
    private int _num = 2;
    private int _idx = 0;

    public void SetNum(int num, int idx) {
        _num = num;
        _idx = idx;
        UpdateBlock();
    }

    private void UpdateBlock()
    {
        TextNum.text = _num.ToString();
        ImgBg.sprite = NumSprites[_idx];
    }

    public int GetNum() {
        return _num;
    }

    public void Merge() {
        _num *= 2;
        _idx += 1;
        UpdateBlock();
    }
}
